<?php session_start(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<?php 
include('js/funcion.inc');
$nick=$_POST["user"];
$pass=$_POST["pass"];
if(trim($nick) != "" && trim($pass) != ""){
    conecta();
    $sql="SELECT * FROM usuarios WHERE usuario='".$nick."'";
    $cons = mysql_query($sql);
    if($row = mysql_fetch_array($cons)){
        if($row['password'] == $pass){
            $_SESSION['user'] = $row['usuario'];
            $_SESSION['name']= $row['nombre'];
            $_SESSION['cod'] = $row['id'];
            $_SESSION['type']='administrador';
            echo'<SCRIPT LANGUAGE="javascript">location.href = "inicioAdmin.php";</SCRIPT>';
        }else{ 
            $mens= "Contraseña incorrecta.";
            echo'<SCRIPT LANGUAGE="javascript">location.href = "login.php?mens='.$mens.'";</SCRIPT>';}
    }else{
        $mens= "No se encontró al usuario.";
        echo'<SCRIPT LANGUAGE="javascript">location.href = "login.php?mens='.$mens.'";</SCRIPT>';}
}else{echo 'Debe especificar un usuario y password';}
?>
</body>
</html>